import { downLoadXlsx } from '@/utils/downloadfile';
import { request } from 'umi';

// 查询字典类型列表
export async function getDictTypeList(params) {
  const queryString = new URLSearchParams(params).toString();
  return request(`/api/system/dict/type/list?${queryString}`, {
    data: params,
    method: 'GET',

  });
}

// 查询字典类型详细
export function getDictType(dictId) {
  return request(`/api/system/dict/type/${dictId}`, {
    method: 'GET',
  });
}

// 查询字典数据详细
export function getDict(dictType) {
  return request(`/api/system/dict/data/type/${dictType}`, {
    method: 'GET',
  });
}

// 新增字典类型
export async function addDictType(params) {
  return request('/api/system/dict/type', {
    method: 'POST',
    data: params,
  });
}

// 修改字典类型
export async function updateDictType(params) {
  return request('/api/system/dict/type', {
    method: 'PUT',
    data: params,
  });
}

// 删除字典类型
export async function removeDictType(ids) {
  return request(`/api/system/dict/type/${ids}`, {
    method: 'DELETE',
  });
}

// 导出字典类型
export function exportDictType(params) {
  return downLoadXlsx(`/api/system/dict/type/export`, { params }, `dict_type_${new Date().getTime()}.xlsx`);
}
